package capricornus.components.utils.mouse
{
	import flash.display.InteractiveObject;
	import flash.utils.Dictionary;

	public class MouseUtils
	{
		private static var _dict:Dictionary;
		
		private static function get dict():Dictionary
		{
			if( _dict==null ) _dict = new Dictionary();
			return _dict;
		}
		
		/**
		 * 添加一直鼠标按下的功能
		 * 添加后，如果鼠标按住不放的时候，dis也会发出MouseDown事件 
		 * @param dis
		 * 
		 */		
		public static function addPress( dis:InteractiveObject ):void
		{
			if( dict[dis]==null )
			{
				var mpc:MousePressController = new MousePressController(dis);
				dict[dis] = mpc;
			}
		}
		
		/**
		 * 去除鼠标按下功能 
		 * @param dis
		 * 
		 */		
		public static function removePress( dis:InteractiveObject ):void
		{
			var mpc:MousePressController;
			if( (mpc=dis[dis]) != null )
			{
				delete dis[dis];
				mpc.destroy();
			}
		}
	}
}